package com.lora.communication.mqtt;

import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * mqtt开关类,当mqtt服务限额时，可通过控制该类的变量，实现关闭mqtt服务的主题订阅
 */
@Component
public class MqttThreadControlVariable {

    public static volatile boolean isError = false;
    public static volatile boolean isClose = false;

    private long sleepTime=10*1000;

    @Async("executor")
    public void changeVolatile() {
        try {
            Thread.sleep(sleepTime);
            this.isError=true;
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
